/**
 * Created by chenyong on 2015/7/16.
 */

function AuthorizationError(message, code, uri, status) {
    if (!status) {
        switch (code) {
            case 'access_denied': status = 403; break;
            case 'server_error': status = 502; break;
            case 'temporarily_unavailable': status = 503; break;
        }
    }

    Error.call(this);
    Error.captureStackTrace(this, arguments.callee);
    this.name = 'AuthorizationError';
    this.message = message;
    this.code = code || 'server_error';
    this.uri = uri;
    this.status = status || 500;
}

/**
 * 继承自 `Error`.
 */
AuthorizationError.prototype.__proto__ = Error.prototype;

module.exports = AuthorizationError;